<template>
  <div class="about">
    <input type="text" placeholder="please input username" v-model="username">
    <button @click="handleEnterBtnClick">登录</button>
  </div>
</template>

<script>
  export default {
    name: 'Login',
    data() {
      return {
        username: ''
      }
    },
    methods: {
      handleEnterBtnClick() {
        const username = this.username.trim()

        if (username.length < 6) {
          alert('用户名不小于六位')
          return
        }

        localStorage.setItem('username', username)
        this.$router.push('/')
      }
    }
  }
</script>